 /** \file btPwm.h
  **
  ** base time for PWM output head  file
  **
  ** History:
  **   - Thursday, November 07, 2013  1.0  Mark  First Version
  *************************************************************************/

 #ifndef __BTPWM_H__
 #define __BTPWM_H__

 /*****************************************************************************/
 /* Include files                                                             */
 /*****************************************************************************/
 #include "mcu.h"
 #include "base_types_l3.h"
 #include "bt.h"
 /*****************************************************************************/
 /* Local pre-processor symbols/macros ('#define')                            */
 /*****************************************************************************/
#ifndef CLOCK_FREQ_APB1
    #ifdef __HCLK
        #define CLOCK_FREQ_APB1  __HCLK>>(APBC1_PSR_Val & 0x03)
    #else
        #define CLOCK_FREQ_APB1  40000000UL
    #endif
#endif

#define PWM_CYCLE(x)    (CLOCK_FREQ_APB1/4000000 * x)

/* pulse output mode specifications */
#define PWM_PULSE_L         (0U)       /* "L" level     */
#define PWM_PULSE_H         (1U)       /* "H" level     */
#define PWM_PULSE_NORMAL    (2U)       /* waveform output      */

#define STRG	0x0001
#define CTEN	0x0002
 /*****************************************************************************/
 /* Global variable definitions (declared in header file with 'extern')       */
 /*****************************************************************************/

 /*****************************************************************************/
 /* Local type definitions ('typedef')                                        */
 /*****************************************************************************/
 /* PWM channel */
enum EM_PWM_CH
{
    PWM_CH0=0,               /* ch.0   PWM    */
    PWM_CH1,                 /* ch.1   PWM    */
    PWM_CH2,                 /* ch.2   PWM    */
    PWM_CH3,                 /* ch.3   PWM    */
    PWM_CH4,                 /* ch.4   PWM    */
    PWM_CH5,                 /* ch.5   PWM    */
    PWM_CH6,                 /* ch.6   PWM    */
    PWM_CH7,                 /* ch.7   PWM    */
};
 /*****************************************************************************/
 /* Local variable definitions ('static')                                     */
 /*****************************************************************************/
boolean_t PWM_Init();
boolean_t btPwm_Init(uint8_t u8Pwm, uint16_t cycle, uint8_t duty);
void btPwm_Deinit(uint8_t u8Pwm);
void btPwmStart(uint8_t u8Pwm);
void btPwmStop(uint8_t u8Pwm);
void PWMSet(uint8_t u8Pwm, uint16_t cycle, uint8_t duty);
 #endif
